<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //obj 传入的全选按钮
        function f(obj) {
            let cs = document.getElementsByName('c');
            //当对象被选中， checked= true
            cs.forEach(v => v.checked = obj.checked)
        }
    </script>

</head>

<body>
    <input type="checkbox" id="sel" onclick="f(this)">全选
    <hr/>
    <input type="checkbox" name="c">选择1<br/>
    <input type="checkbox" name="c">选择1<br/>
    <input type="checkbox" name="c">选择1<br/>
    <input type="checkbox" name="c">选择1<br/>
    <input type="checkbox" name="c">选择1<br/>
</body>
</html>

